Page({
    /**
     * Page initial data
     */
    data: {
        refresherTriggered: false,
        list: <any>[]
    },
    /**
     * Lifecycle function--Called when page load
     */
    onLoad() {
        this.setData({
            list: this.queryList(0)
        });
    },
    queryList(offset: number): any[] {
        let list = []

        for (let i = 0; i < 10; i++) {
            list.push({
                id: i + offset,
                name: `name - ${i + offset}`,
                price: 1000000,
                dateCreated: new Date().toLocaleDateString(),
            })
        }

        return list
    },
    onScrollViewRefresh(): void {
        setTimeout(() => {
            this.setData({
                refresherTriggered: false,
                list: this.queryList(0)
            });
        }, 1000)
    },
    onScrollViewToLower(): void {
        if (this.data.list.length < 20) {
            let list = this.queryList(this.data.list.length);

            this.setData({
                list: this.data.list.concat(list)
            });
        }
    },
})